import os
from Common.Po.jiekou_po.rest_client import RestClient


BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# todo: 这里是要读取config.ini中的配置
api_root_url = 'a'


class User(RestClient):
    """用户相关的接口封装"""
    def __init__(self, api_root_url, **kwargs):
        super(User, self).__init__(api_root_url, **kwargs)

    def list_all_users(self, **kwargs):
        """获取用户列表"""
        return self.get("/users", **kwargs)

    def list_one_user(self, username, **kwargs):
        """获取当个用户接口"""
        return self.get("/users/{}".format(username), **kwargs)

    def register(self, **kwargs):
        """用户注册接口"""
        return self.post("/register", **kwargs)

    def login(self, **kwargs):
        """用户登录接口"""
        return self.post("/login", **kwargs)

    def update(self, user_id, **kwargs):
        """用户更新接口"""
        return self.put("/update/user/{}".format(user_id), **kwargs)

    def delete(self, name, **kwargs):
        """用户删除接口"""
        return self.post("/delete/user/{}".format(name), **kwargs)


user = User(api_root_url)